package com.md.lesson8;

import java.util.Scanner;

public class Factorial {
	public static void fac(long a) {
		long result3 = 0;
		for(int c = 1;c <= a;c++) {
			long result1 = 1;
			long result2 = 0;
			for(int b = 1;b <= c;b++) {
				result1 *= b;
				result2 += result1;
			}
			System.out.println(result2);
			result3 += result2;
		}
		System.out.println("最终结果是；" + result3);
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		
		System.out.println("请输入一个数：");
		long a = s.nextLong();
		
		fac(a);

	}

}
